<?php
include "../../../lib/list.php";
if($_POST['mode']=='insert'){
	$no			=	$_POST['no'];
	$name		=	$_POST['name'];
	$tax_part	=	$_POST['tax_part'];
	$tax_per	=	$_POST['tax_per'];
	$note		=	$_POST['note'];

	for($i=0;$i<count($no);$i++){
	if(!$name[$i]){
		echo("
	    <script>
	      window.alert('부문명을 입력해주세요.');
	      window.alert('내용 입력에 실패했습니다.');
		  location.href='view.php';
	      </script>");
		return;
	}
	else{
		if(!$no[$i]){
			$no[$i] = 'NULL';
		}
		
		$query = sprintf("INSERT INTO uatp_bumun(no,name,tax_part,tax_per,note) 
										  VALUES(%d,'%s','%s',%f,'%s')
				ON DUPLICATE KEY UPDATE name='%s',tax_part='%s',tax_per=%f,note='%s'",
		$no[$i],
		addslashes(clean($name[$i])),
		addslashes(clean($tax_part[$i])),
		$tax_per[$i],
		addslashes(clean($note[$i])),
		addslashes(clean($name[$i])),
		addslashes(clean($tax_part[$i])),
		$tax_per[$i],
		addslashes(clean($note[$i])));
		DBquery($query);
	}
	}
	mysql_close();
	echo "<script>
				window.alert('그룹을 입력했습니다.');
				location.href='view.php';
		  </script>";
}
if($_POST['mode']=='close'){

}